package com.kai.module_cartoon.cart

import android.app.Application
import androidx.lifecycle.LiveData
import com.kai.base.base.basic.model.BaseModel

import com.kai.module_cartoon.api.APIHomePage
import com.kai.module_cartoon.widget.HorizonBean

/**
 * @Author: 小强同学
 * @Date:  2021/3/18 17:34
 * @Description:  ViewMode 处理数据
 */
class CartoonViewMode(application: Application) : BaseModel(application) {
    /**
     * 获取头部数据
     * */
    fun loadHeadData(): LiveData<MutableList<CartoonBean.HeadlineBean>> = emit {
        APIHomePage.getInstance().getHeadHtml()
    }

    /**
     * 获取Banner数据
     * */
    fun loadBannerData(): LiveData<MutableList<CartoonBean.BannerData>> = emit {
        var list1 = APIHomePage.getInstance().getBannerData()
        if (list1.size == 1) {
            list1.add(list1[0])
        }
        list1
    }

    /**
     * 获取漫画精选数据
     * */
    fun loadSelected():LiveData<MutableList<HorizonBean>> = emit {
        APIHomePage.getInstance().getSelected()
    }
    /**
     * 获取今日热门数据
     * */
    fun loadHot():LiveData<MutableList<HorizonBean>> = emit {
        APIHomePage.getInstance().getHot()
    }
    /**
     * 获取最近更新数据
     * */
    fun loadUpdate():LiveData<MutableList<HorizonBean>> = emit {
        APIHomePage.getInstance().getUpdate()
    }
    /**
     * 获取最近上架数据
     * */
    fun loadLately():LiveData<MutableList<HorizonBean>> = emit {
        APIHomePage.getInstance().getLately()
    }
}